package com.lgr.store.service;


import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.lgr.store.dao.DepDAO;
import com.lgr.store.vo.DepVo;
import com.lgr.store.vo.EmpVo;

import javax.annotation.Resource;
import java.util.List;

@Service
public class DepService {
    @Resource
    private  DepDAO depDAO;
    //查询
    @Transactional
    public List<DepVo> list() {
        List<DepVo> depList = depDAO.listAll();
        return depList;
    }
    //查询记录数
    @Transactional
    public int count(DepVo depVo) {
        return depDAO.getcount(depVo);
    }
    //新增
    @Transactional
    public void add(DepVo depVo) {
        depDAO.add(depVo);
    }
    //删除
    @Transactional
    public void delete(Integer depid) {
        depDAO.deleteById(depid);
    }
    //修改
    @Transactional
    public void update(DepVo depVo) {
        depDAO.update(depVo);
    }
    //获取一条数据
    @Transactional
    public DepVo findById(Integer depid) {
        return depDAO.findById(depid);
    }
    //查找父部门
    @Transactional
    public List<DepVo> findByParentId(int parentId) {
        return depDAO.findByParentId(parentId);
    }
    //查找所有用户资料
    @Transactional
    public List<EmpVo> listEmp() {
        return  depDAO.listEmp();
    }
    //通过部门负责人查找部门
    @Transactional
    public List<DepVo> listChairman(String empId) {
        return  depDAO.listChairman(empId);
    }
    //通过部门id查找负责人资料
    @Transactional
    public List<EmpVo> selectEmp(int depId) {
        return  depDAO.selectEmp(depId);
    }

}